import 'dart:async';

import 'package:rxdart/rxdart.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sweet_app/bloc/bloc_provider.dart';
import 'package:sweet_app/http/api.dart';
import 'package:sweet_app/model/user.dart';

class SearchBloc implements BaseBloc {

  final StreamController<SearchBody> _searchSubject = StreamController<SearchBody>();

  Sink<SearchBody> get _searchSink => _searchSubject.sink;

  Stream<SearchBody> get searchStream => _searchSubject.stream;

  @override
  void dispose() {
    _searchSubject.close();
  }

  add(SearchBody body) {
    _searchSink.add(body);
  }

}


class SearchBody {
  final User user;
  final bool friendFlag;

  SearchBody({this.user, this.friendFlag});

  static SearchBody fromJson(Map<String, dynamic> map) {
    return SearchBody(user: map["user"], friendFlag: map["friendFlag"]);
  }

  @override
  String toString() {
    return 'SearchBody{user: $user, friendFlag: $friendFlag}';
  }

}